﻿/*****************************************************************************  

 Version: 0.1
 Website: http://www.visuagile.com/
 
 Copyright (c) Yoganand R. All rights reserved.
 For continued development and updates, visit http://yogsbreath.net
 
 ******************************************************************************/

using System;
using System.Collections;
using System.Collections.Generic;
using NHibernate;
using Spring.Data.NHibernate.Support;

using VisualAgile.IDAL;
using VisualAgile.Model;
using Spring.Data.NHibernate;
using NHibernate.Engine;

namespace VisualAgile.DAL
{
    public class RoleDao : BaseDao<Role>, IRoleDao
    {
        protected override HibernateTemplate getBaseDAO()
        {
            return HibernateTemplate;
        }

        public Role FindByName(string roleName)
        {
            IList Role = HibernateTemplate.Find("from Role where Name = ?", roleName);

            if (Role != null && Role.Count > 0)
                return Role[0] as Role;
            
            return null;
        }

        public Role FindById(int? roleId)
        {
            IList Role = HibernateTemplate.Find("from Role where RoleID = ?", roleId);

            if (Role != null && Role.Count > 0)
                return Role[0] as Role;

            return null;
        }        
    }
}
